import java.util.Arrays;

public class OddBeforeEven {
    public static void main(String[] args) {
        int []arr={2,3,4,5,6,7,8,9};
        oddBeforeEven(arr);
        String ret=Arrays.toString(arr);
        System.out.println(ret);
    }

    public static void oddBeforeEven(int []array){
        int i=0;
        int j= array.length-1;
        int swap;
        while(i!=j){
            if(array[i]%2!=0){
                i++;
            }
            else{
                if(array[j]%2==0){
                    j--;
                }
                else{
                    swap=array[i];
                    array[i]=array[j];
                    array[j]=swap;
                    i++;
                    j--;
                }
            }
        }
    }
}
